package com.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dao.ZhichuxinxiDao;
import com.entity.ZhichuxinxiEntity;
import com.entity.view.ZhichuxinxiView;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.service.ZhichuxinxiService;
import com.utils.PageUtils;
import com.utils.Query;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * 支出信息 服务实现类
 */
@Service("zhichuxinxiService")
@Transactional
public class ZhichuxinxiServiceImpl extends ServiceImpl<ZhichuxinxiDao, ZhichuxinxiEntity> implements ZhichuxinxiService {

    @Override
    public PageUtils queryPage(Map<String,Object> params) {
        if(params != null && (params.get("limit") == null || params.get("page") == null)){
            params.put("page","1");
            params.put("limit","10");
        }
        Page<ZhichuxinxiView> page =new Query<ZhichuxinxiView>(params).getPage();
        PageHelper.startPage(Integer.parseInt(params.get("page").toString()), Integer.parseInt(params.get("limit").toString()));
        PageInfo<ZhichuxinxiView> zhichuxinxiViewPageInfo = new PageInfo<>(baseMapper.selectListView(page, params));
        page.setTotal(zhichuxinxiViewPageInfo.getTotal());
        page.setRecords(zhichuxinxiViewPageInfo.getList());
        return new PageUtils(page);
    }


}
